package com.itheima.job6;

import java.util.concurrent.*;

class Calculator implements Callable {
    @Override
    public Object call() throws Exception {
        int sum =0;
        for (int i = 1; i < 101; i++) {
            sum+=i;
        }
        return sum;
    }
}
public class Test {
    public static void main(String[] args) {
        //创建线程池
        ExecutorService threadPool = Executors.newFixedThreadPool(3);
        Future<Integer> f = threadPool.submit(new Calculator());
        int sum = 0;
        try {
             sum = f.get();
        } catch (Exception e) {
            e.printStackTrace();

        }
        System.out.println("结果"+sum );
    }
}
